﻿<UserControl x:Class="EpiNEXT.WPF.FormDesigner.Pages.FormDesigner"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:view="clr-namespace:EpiNEXT.WPF.FormDesigner"
             xmlns:local="clr-namespace:EpiNEXT.WPF.FormDesigner.Pages"
             xmlns:controls="clr-namespace:EpiNEXT.WPF;assembly=EpiNEXT.WPF"
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             mc:Ignorable="d" 
             d:DesignHeight="1040" d:DesignWidth="780">
    <UserControl.Resources>
        <Style x:Key="SliderIncrement" TargetType="{x:Type RepeatButton}">
            <Setter Property="SnapsToDevicePixels" Value="true"/>
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="IsTabStop" Value="false"/>
            <Setter Property="Focusable" Value="false"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type RepeatButton}">
                        <!--<Canvas HorizontalAlignment="Right">
                            <Canvas Margin="6,0,0,0">
                                <Path Stretch="Fill" Height="14" Width="14" Fill="{StaticResource WindowBackgroundBrush}" Data="F1 M 35,19L 41,19L 41,35L 57,35L 57,41L 41,41L 41,57L 35,57L 35,41L 19,41L 19,35L 35,35L 35,19 Z "/>
                            </Canvas>
                        </Canvas>-->
                        <Grid Background="Transparent" HorizontalAlignment="Right" Margin="0, 0, 0, 0">
                            <Rectangle Fill="{StaticResource WindowBackgroundBrush}"
                                       Width="8" Height="2" HorizontalAlignment="Center" VerticalAlignment="Center" />
                            <Rectangle Fill="{StaticResource WindowBackgroundBrush}"
                                       Width="2" Height="8" HorizontalAlignment="Center" VerticalAlignment="Center" />
                            <!--<Canvas Margin="-10,6,0,0">
                                <Path Stretch="Fill" Height="2" Width="14" Fill="{StaticResource WindowBackgroundBrush}" Data="F1 M 19,38L 57,38L 57,44L 19,44L 19,38 Z "/>
                            </Canvas>-->
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="ThumbBall" TargetType="{x:Type Thumb}">
            <Setter Property="SnapsToDevicePixels" Value="True"/>
            <Setter Property="OverridesDefaultStyle" Value="True"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Rectangle Fill="{StaticResource WindowBackgroundBrush}"
                                   Height="14"
                                   Width="5"
                                   VerticalAlignment="Center"
                                   x:Name="TrackBall"
                                   />

                        <!--<Path StrokeThickness="0.250000" Stroke="#FFA2A2A2" StrokeMiterLimit="1.000000" 
                              Data="F1 M 0,3.455078 C 0,1.615723 1.490234,0.125000 3.330078,0.125000 C 5.168945,0.125000 6.659179,1.615723 6.659179,3.455078 C 6.659179,5.292969 5.168945,6.784180 3.330078,6.784180 C 1.490234,6.784180 0,5.292969 0,3.455078 Z" x:Name="TrackBall" Opacity="1" Fill="{StaticResource WindowBackgroundBrush}" />-->

                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="TrackBall" Property="Fill" Value="White"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter TargetName="TrackBall" Property="Opacity" Value="0.5"/>
                            </Trigger>
                        </ControlTemplate.Triggers>

                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>


        <Style x:Key="SliderDecrement" TargetType="{x:Type RepeatButton}">
            <Setter Property="SnapsToDevicePixels" Value="true"/>
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="IsTabStop" Value="false"/>
            <Setter Property="Focusable" Value="false"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type RepeatButton}">
                        <Grid HorizontalAlignment="Left" Background="Transparent" Margin="0, 0, 15, 0">
                            <Rectangle Fill="{StaticResource WindowBackgroundBrush}"
                                       Width="6" Height="2" HorizontalAlignment="Center" VerticalAlignment="Center" />
                            <!--<Canvas Margin="-10,6,0,0">
                                <Path Stretch="Fill" Height="2" Width="14" Fill="{StaticResource WindowBackgroundBrush}" Data="F1 M 19,38L 57,38L 57,44L 19,44L 19,38 Z "/>
                            </Canvas>-->
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="SliderStyle" TargetType="{x:Type Slider}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Slider}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto" MinHeight="{TemplateBinding Slider.MinHeight}"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>

                            <Rectangle Margin="0, 0, 0, 0" Grid.Row="1" Height="1" Fill="{StaticResource WindowBackgroundBrush}" />
                            <!--<Path Margin="15,4,0,0" Grid.Row="1" Fill="{StaticResource WindowBackgroundBrush}" Data="F1 M 0,2.701660 L 0,4.179688 L 170.306641,4.179688 L 170.306641,2.701660 L 0,2.701660 Z"/>-->

                            <Track Grid.Row="1" Name="PART_Track" Visibility="Visible">
                                <Track.DecreaseRepeatButton>
                                    <RepeatButton Margin="-15, 0, 0, 0" Style="{StaticResource SliderDecrement}"
                                  Command="Slider.DecreaseLarge" />
                                </Track.DecreaseRepeatButton>
                                <Track.Thumb>
                                    <Thumb Margin="0,0,0,0" Style="{StaticResource ThumbBall}" />
                                </Track.Thumb>
                                <Track.IncreaseRepeatButton>
                                    <RepeatButton Margin="0, 0, -15, 0" Style="{StaticResource SliderIncrement}"
                                  Command="Slider.IncreaseLarge" />
                                </Track.IncreaseRepeatButton>
                            </Track>
                        </Grid>

                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid x:Name="grdDesigner" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="8" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <DockPanel Grid.ColumnSpan="2" Grid.Row="1" LastChildFill="True" x:Name="panelProgressBar">
        </DockPanel>

        <!-- #252525-->
        <!--<Grid x:Name="panelNavigation" Grid.Row="0" Grid.ColumnSpan="100" Background="{StaticResource MediumTextBrush}">-->
        <Grid x:Name="panelTools" Grid.Row="0" Grid.ColumnSpan="100" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition MinWidth="240" Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <StackPanel Grid.Column="0" Orientation="Horizontal" Margin="2, 4, 2, 4">
                <controls:CircleButton Command="{Binding SaveRecordAsyncCommand}" IsEnabled="{Binding Path=SaveRecordCommand.CanExecute}" PathData="F1 M 20.5833,20.5833L 55.4167,20.5833L 55.4167,55.4167L 45.9167,55.4167L 45.9167,44.3333L 30.0833,44.3333L 30.0833,55.4167L 20.5833,55.4167L 20.5833,20.5833 Z M 33.25,55.4167L 33.25,50.6667L 39.5833,50.6667L 39.5833,55.4167L 33.25,55.4167 Z M 26.9167,23.75L 26.9167,33.25L 49.0833,33.25L 49.0833,23.75L 26.9167,23.75 Z " />
                <!--<StackPanel Width="6" />
                <controls:CircleButton PathData="F1 M 19,50L 28,34L 63,34L 54,50L 19,50 Z M 19,28.0001L 35,28C 36,25 37.4999,24.0001 37.4999,24.0001L 48.75,24C 49.3023,24 50,24.6977 50,25.25L 50,28L 53.9999,28.0001L 53.9999,32L 27,32L 19,46.4L 19,28.0001 Z" />-->
                <StackPanel Width="6" />
                <controls:CircleButton Command="{Binding UnloadFormCommand}" IsEnabled="{Binding Path=SaveRecordAsyncCommand.CanExecute}" PathData="F1 M 26.9166,22.1667L 37.9999,33.25L 49.0832,22.1668L 53.8332,26.9168L 42.7499,38L 53.8332,49.0834L 49.0833,53.8334L 37.9999,42.75L 26.9166,53.8334L 22.1666,49.0833L 33.25,38L 22.1667,26.9167L 26.9166,22.1667 Z" />
                <!--<StackPanel Width="6" />
                <controls:CircleButton Click="PrintButton_Click" Command="{Binding TogglePrintPreviewCommand}" IsEnabled="{Binding Path=SaveRecordAsyncCommand.CanExecute}" PathData="F1 M 25,27L 25,17L 51,17L 51,27L 47,27L 47,21L 29,21L 29,27L 25,27 Z M 16,28L 60,28L 60,51L 52,51L 52,46L 55,46L 55,33L 21,33L 21,46L 24,46L 24,51L 16,51L 16,28 Z M 25,39L 28,39L 28,52L 35,52L 35,59L 48,59L 48,39L 51,39L 51,62L 33,62L 25,54L 25,39 Z M 46,55L 38,55L 38,52L 46,52L 46,55 Z M 46,49L 30,49L 30,46L 46,46L 46,49 Z M 46,43L 30,43L 30,40L 46,40L 46,43 Z" />-->

                <!--<StackPanel Width="6" />
                <controls:CircleButton Command="{Binding ToggleSearchCommand}" PathData="F1 M 42.5,22C 49.4036,22 55,27.5964 55,34.5C 55,41.4036 49.4036,47 42.5,47C 40.1356,47 37.9245,46.3435 36,45.2426L 26.9749,54.2678C 25.8033,55.4393 23.9038,55.4393 22.7322,54.2678C 21.5607,53.0962 21.5607,51.1967 22.7322,50.0251L 31.7971,40.961C 30.6565,39.0755 30,36.8644 30,34.5C 30,27.5964 35.5964,22 42.5,22 Z M 42.5,26C 37.8056,26 34,29.8056 34,34.5C 34,39.1944 37.8056,43 42.5,43C 47.1944,43 51,39.1944 51,34.5C 51,29.8056 47.1944,26 42.5,26 Z" />-->

                <StackPanel Width="6" Visibility="{Binding SelectedForm.IsRelatedForm, Converter={StaticResource BooleanToVisibilityConverter}}" />
                <controls:CircleButton
                    Command="{Binding ReturnToParentCommand}"
                    Visibility="{Binding SelectedForm.IsRelatedForm, Converter={StaticResource BooleanToVisibilityConverter}}"
                    PathData="F1 M 57,42L 57,34L 32.25,34L 42.25,24L 31.75,24L 17.75,38L 31.75,52L 42.25,52L 32.25,42L 57,42 Z" />


                <StackPanel Width="6" Visibility="{Binding SelectedForm.IsRelatedForm, Converter={StaticResource BooleanToVisibilityConverter}}" />
                <controls:CircleButton
                    Command="{Binding ReturnToTopMostParentCommand}"
                    Visibility="{Binding SelectedForm.IsRelatedForm, Converter={StaticResource BooleanToVisibilityConverter}}"
                    PathData="F1 M 24.0033,56.0078L 24.0033,38.0053L 22.0031,40.0056L 19.0027,35.0049L 38.0053,20.0028L 45.0063,25.5299L 45.0063,21.753L 49.0068,21.0029L 49.0068,28.6882L 57.008,35.0049L 54.0075,40.0056L 52.0073,38.0053L 52.0073,56.0078L 24.0033,56.0078 Z M 38.0053,26.9204L 27.0038,36.005L 27.0038,53.0074L 33.0046,53.0074L 33.0046,42.006L 43.006,42.006L 43.006,53.0074L 49.0068,53.0074L 49.0068,36.005L 38.0053,26.9204 Z" />
            </StackPanel>
        </Grid>

        <ScrollViewer Grid.Row="2" Grid.Column="1" Visibility="Visible" >
            <controls:FormDesignerPages ItemsSource="{Binding SelectedForm.PagesView}" IsEnabled="{Binding Project.Database.IsProcessing, Converter={StaticResource BooleanInverter}}" >
                <controls:FormDesignerPages.LayoutTransform>
                    <ScaleTransform  
                              ScaleX="{Binding ElementName=sliderZoom, Path=Value}" 
                              ScaleY="{Binding ElementName=sliderZoom, Path=Value}" />
                </controls:FormDesignerPages.LayoutTransform>
            </controls:FormDesignerPages>
        </ScrollViewer>

        <Grid Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Height="24" Background="#1E4A96">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <StackPanel Orientation="Horizontal" Grid.Column="0">
                <TextBlock Visibility="{Binding Project.Database.IsProcessing, Converter={StaticResource BooleanToVisibilityConverter}}" Margin="4" Foreground="{StaticResource WindowBackgroundBrush}" Text="{Binding CurrentStatusMessage}" />
                <StackPanel Width="32" />
                <Border Margin="3" BorderThickness="1" BorderBrush="{StaticResource WindowBackgroundBrush}" Visibility="{Binding Project.Database.IsProcessing, Converter={StaticResource BooleanToVisibilityConverter}}">
                    <ProgressBar Margin="2" Background="Transparent" Foreground="{StaticResource WindowBackgroundBrush}"  Width="120" HorizontalAlignment="Stretch" IsIndeterminate="False" Value="{Binding Project.Database.ProcessingProgress}" />
                </Border>
            </StackPanel>

            <StackPanel Orientation="Horizontal" Grid.Column="0">
                <TextBlock Visibility="{Binding CurrentField, Converter={StaticResource LengthToVisibilityConverter}}" Margin="4" Foreground="{StaticResource WindowBackgroundBrush}" Text="{Binding CurrentField}" />
            </StackPanel>

            <StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right">
                <TextBlock FontSize="8pt" Margin="0, 0, 25, 0" Foreground="{StaticResource WindowBackgroundBrush}" HorizontalAlignment="Center" VerticalAlignment="Center"
                           Text="{Binding ElementName=sliderZoom, Path=Value, Converter={StaticResource SliderValueConverter}}"
                           ></TextBlock>

                <Slider IsSnapToTickEnabled="True" TickFrequency="0.05" Value="1" Minimum="0.5" Maximum="3" SmallChange="0.10" LargeChange="0.20" TickPlacement="BottomRight"
                        x:Name="sliderZoom"
                        SnapsToDevicePixels="True"
                        Margin="4, 2, 24, 4" VerticalAlignment="Center" Style="{StaticResource SliderStyle}" Width="100" Height="Auto"></Slider>
            </StackPanel>
        </Grid>
    </Grid>

</UserControl>
